package br.com.rafael.gestorinvestimentos.DAO;

import java.util.List;
import org.hibernate.Session;

import br.com.rafael.gestorinvestimentos.model.ItemPortfolio;

public class ItemPortfolioDAO {
	
	private Session session;
	
	public ItemPortfolioDAO(Session session){
		this.session = session;
	}	
	
	public void insert (ItemPortfolio itemPortfolio){
		this.session.save(itemPortfolio);
	}
	
	public void update (ItemPortfolio itemPortfolio){
		this.session.merge(itemPortfolio);
	}
	
	public void delete (ItemPortfolio itemPortfolio){
		this.session.delete(itemPortfolio);
	}
	
	public ItemPortfolio getItemPortfolio (int id){
		return (ItemPortfolio) session.load(ItemPortfolio.class, id);
	
	}
	
	public List getList (){
		return this.session.createCriteria(ItemPortfolio.class).list();
	}
	
}
